package leetcode_301_400;

public class LeeCode_343 {
    public static void main(String[] args) {
        System.out.println(integerBreak(10));
        System.out.println(integerBreak(2));
        System.out.println(integerBreak(10));
    }
    private static int integerBreak(int n) {
        if (n == 2)
            return 1;
        if (n == 3)
            return 3;
        int ans = 1;
        while (n > 4){
            n -= 3;
            ans *= 3;
        }
        return ans * (n == 0 ? 1 : n);
    }
}
